using System;
using System.Data;

using SBCommon.Data;
using SBCommon.Validation;
using SecurityModule.Entity;


namespace SecurityModule.Service
{
    public class DataObjectAndUserGroupService
    {
        
        public void Save(DataObjectAndUserGroup entity)
        {
            ValidationManager.Validate(entity);
            DataContext dc = new DataContext();
            dc.Save(entity);
        }

        
        public void Delete(int id)
        {
            DataContext dc = new DataContext();
            dc.Delete<DataObjectAndUserGroup>(id);
        }

        
        public DataObjectAndUserGroup Single(int id)
        {
            DataContext dc = new DataContext();
            DataObjectAndUserGroup entity = dc.Single<DataObjectAndUserGroup>(id);
            return entity;
        }

        
        public DataSet Query(string whereClause, string orderClause, int startRowIndex, int maximumRows)
        {
            IQuery query = DataContext.CreateQuery();
            DataSet ds = query.Where(whereClause).OrderBy(orderClause)
                .Skip(startRowIndex).Take(maximumRows)
                .ToDataSet<DataObjectAndUserGroup>();
            return ds;
        }

    }
}

